package com.andy.note.main;

import cn.hutool.core.date.ChineseDate;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ReflectUtil;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;

/**
 * 
 * 
 *
 * @author Andy<908119428@qq.com>
 * @version $Revision: 1.1 $ $Date: 2021年6月30日 上午11:40:53 $
 */
public class AB {
    

    public static void main(String[] args) throws Exception {
//        ChineseDate cd = ReflectUtil.newInstance(ChineseDate.class, DateUtil.parse("2021-07-02"));
//        Map<String, Field> fieldMap = ReflectUtil.getFieldMap(cd.getClass().getDeclaringClass());
        ChineseDate cd = new ChineseDate(DateUtil.parse("2021-07-02"));
        Field field = cd.getClass().getDeclaredField("year");
        field.setAccessible(true);
        System.out.println(field.get(cd));
        
        String fieldName = ReflectUtil.getFieldName(field);
        System.out.println(fieldName);
        
        Object fieldValue = ReflectUtil.getFieldValue(cd, "year");
        System.out.println(fieldValue);
        
        Method methodByName = ReflectUtil.getMethodByName(ChineseDate.class, "lunar2solar");
        methodByName.setAccessible(true);
        Object invoke = methodByName.invoke(cd, 2021,7,2,false);
        System.out.println(invoke);
        
        Map<String, Field> fieldMap = ReflectUtil.getFieldMap(ChineseDate.class);
        Field field2 = fieldMap.get("year");
        field2.setAccessible(true);
        System.out.println(field2.get(cd));
        
    }
}
